//
//  LGTeamDetailMemberCell.m
//  HeartDiseaseManage
//
//  Created by 1234 on 2023/2/16.
//

#import "LGTeamDetailMemberCell.h"

@interface LGTeamDetailMemberCell()
/**   */
@property (nonatomic , strong)UIImageView *imageView;
/**   */
@property (nonatomic , strong)UILabel *nameLabel;
/**   */
@property (nonatomic , strong)UILabel *tipLabel;

@end

@implementation LGTeamDetailMemberCell

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        [self.contentView addSubview:self.imageView];
        [self.contentView addSubview:self.nameLabel];
        [self.imageView addSubview:self.tipLabel];
        [self.imageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.contentView).offset(viewPix(5));
            make.centerX.equalTo(self.contentView);
            make.width.height.equalTo(@(viewPix(50)));
        }];
        [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.imageView.mas_bottom).offset(viewPix(7));
            make.left.equalTo(self.contentView).offset(viewPix(5));
            make.right.equalTo(self.contentView).offset(-viewPix(5));
        }];
        [self.tipLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.bottom.right.equalTo(self.imageView);
            make.height.equalTo(@(viewPix(17)));
        }];
    }
    return self;
}


-(void)setModel:(LGTeamMemberModel *)model{
    _model = model;
    [self.imageView sd_setImageWithURL:[NSURL URLWithString:model.avatar] placeholderImage:defaultDoctorPic];
    self.nameLabel.text = model.realname;
    if(model.isleader == YES){
        //队长
        self.tipLabel.hidden = NO;
        self.tipLabel.text = @"队长";
        
    }else if (model.ismanage == YES){
        //管理员
        self.tipLabel.hidden = NO;
        self.tipLabel.text = @"管理员";
        
    }else{
        //成员
        self.tipLabel.hidden = YES;
    }
}

-(void)setIconName:(NSString *)iconName{
    _iconName = iconName;
    self.imageView.image = [UIImage imageNamed:iconName];
    self.tipLabel.hidden = YES;
    self.nameLabel.text = @"";
}

-(UIImageView *)imageView{
    if(!_imageView){
        _imageView = [[UIImageView alloc]init];
        _imageView.cornerRidus = 5;
    }
    return _imageView;
}

-(UILabel *)nameLabel{
    if(!_nameLabel){
        _nameLabel = [UILabel lableWithText:@"" colorString:@"#666666" textFont:LGFont(14) textAlignment:NSTextAlignmentCenter lines:1];
    }
    return _nameLabel;
}

-(UILabel *)tipLabel{
    if(!_tipLabel){
        _tipLabel = [UILabel lableWithText:@"" colorString:@"#FFFFFF" textFont:LGFont(12) textAlignment:NSTextAlignmentCenter lines:1];
        _tipLabel.backgroundColor = [UIColor colorWithString:@"#000000" alpha:0.5];
        _tipLabel.hidden = YES;
    }
    return _tipLabel;
}

@end
